/*
 * @Description:
 * @Date: 2024-02-25 20:49:38
 * @LastEditTime: 2024-03-03 14:02:50
 * @FilePath: /pure-admin-thin/src/user.ts
 */
import { http } from "@/utils/http";

export interface CategoryInfo {
  id: string;
  pid: string;
  name: string;
  summary: string;
}

export interface CategoryResult {
  code: number;
  message: string;
  data: CategoryInfo;
}

export interface CategoryListResult {
  code: number;
  message: string;
  data: CategoryInfo[];
}

export const getCategory = (id: string) => {
  return http.request<CategoryResult>("get", `/category/${id}`, {});
};

export const getCategoryList = () => {
  return http.request<CategoryListResult>("get", `/category`, {});
};

export const getFirstList = () => {
  return http.request<CategoryListResult>("get", `/category/first`, {});
};

export const getSecondList = () => {
  return http.request<CategoryListResult>("get", `/category/second`, {});
};

/** 添加分类 */
export const addCategory = (data?: object) => {
  return http.request<CategoryResult>("post", "/category", { data });
};

export const updateCategory = (id: string, data?: object) => {
  return http.request<CategoryResult>("patch", "/category/" + id, {
    data
  });
};

export const delCategory = (id: string) => {
  return http.request<CategoryResult>("delete", "/category/" + id, {});
};
